C++ String operator[]()30 Aug 2024 | 1 min read This function is used to get a character at position pos in the string. SyntaxConsider a string 'str' and character 'ch' at position 'pos'. Syntax would be: Parameterpos: It defines the position of character which is to be retrieved. Return valueThis function returns the character specified at position pos. Example 1Let's see a simple example. Output: C programs Example 2Let's see an another simple example. Output: 54321 Next TopicC++ Strings |
string empty() function
C++ String empty() This function checks whether the string is empty or not. Function returns a Boolean value either true or false. Syntax Consider a string str. Syntax would be: str.empty(); Parameter This function does not contain any parameter. Return value It returns a Boolean value either 0 or 1 depending upon the conditions....
1 min read
string crend() function
C++ String crend() The crend() function stands for reverse end. It points to the first character of string and returns constant reverse iterator. Syntax Consider a string s. Syntax would be: const_reverse_iterator itr=s.crendO; Parameter It does not contain any parameter. Return value It returns a constant reverse iterator to the reverse end of...
1 min read
string cbegin() function
C++ String cbegin() It gives a reference to the first element of the string. Difference b/w cbegin() and begin() The only difference between cbegin() and begin() is cbegin() returns the constant iterator pointing to the constant value. Syntax Consider a string str. Its syntax would be: str.cbegin(); Parameter This function does not contain...
1 min read
string data() function
C++ String Data() This function copies the characters of the string into an array. It returns the pointer to an array obtained from the conversion of string into array. Syntax Consider a string str and pointer p. Syntax would be: const char* p=str.data(); Parameter This function does not contain any parameter. Return value It...
1 min read
string back() function
C++ String back() Function In C++, the is a member function of the string class in the STL. It is commonly utilized to access the last character of a string. It is utilized on non-empty strings and returns a direct reference to the last character...
6 min read
string find_first_of() function
C++ String find_first_of() Function In the C++ programming language, the is a simple and effective string-searching function. It is commonly utilized to locate the first occurrence of any character from a given set of characters within a string. It scans or checks the string from...
6 min read
string c_str() function
C++ String c_str() Function In the C++ programming language, the c_str() function is commonly utilized to convert a std::string into a C-style string (a null-terminated character array). It is useful when we work with legacy C libraries, system calls, or functions that require const char* instead...
5 min read
string rend() function
C++ String rend() Function In the C++ programming language, the is a member function of the string class that is a part of the STL. The rend() function mainly stands for the reverse end. It is commonly utilized to return a reverse iterator that points...
6 min read
string crbegin() function
C++ String crbegin() The crbegin() function stands for 'reverse beginning'. This function references to the last character of the string. Syntax Consider a string str. Syntax would be: str.crbegin(); Parameter This function does not contain any parameter. Return value This function returns the constant iterator pointing to the last character of the string. Example 1 Let's...
1 min read
string append() function
C++ String append() This function is used to extend the string by appending at the end of the current value. Syntax Consider string str1 and str2. Syntax would be : Str1.append(str2); Str1.append(str2,pos,len); Str1.append(str2,n); Parameters str : String object which is to be appended in another string object. pos : It determines the position of the...
1 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India